from celery_app import celery_app, db
from common.oss_upload import async_upload_to_oss
# from daos.video_library_dao import query_video_library_by_file_name, update_video_library
# from models.biz_enum import VideoLibraryOssStatus


from rules.video_library_rule import describe_video_library_oss_status


@celery_app.task(bind=True, base=celery_app.Task)
def async_upload_video(self, filename, local_path):
    up_result = async_upload_to_oss(filename, local_path)
    if up_result:
        describe_video_library_oss_status(filename, up_result)
        # video_library_orm = query_video_library_by_file_name(filename)
        # if video_library_orm:
        #     video_library_orm.oss_status = VideoLibraryOssStatus.SUCCESS.value if up_result.get(
        #         'status') == 200 else VideoLibraryOssStatus.FAIL.value
        #
        #     need_update_list = ["last_update_time"]
        #     update_video_library(video_library_orm, *need_update_list)

    return ""
